<?php

class MagicPhp_Model {
    public $m_ext = 'model';
    public $c_ext = 'controller';
    public $ext  = '.php';
    protected function importFile($file,$extention = NULL){
       $extention != ''  ? $extention = $extention : $extention = '.php';
        $fiileName = $file.$extention;
        if(file_exists($fiileName)) {
            require_once ($fiileName);
        } else {
            return new ErrorException($fiileName. "Is not exist.");
        }   
    }
    public function defineModel($element,$queryString){
       $str = str_replace('q=index.php/','',$queryString);
       $mvc = explode('/',$str);
       return $mvc[$element] ; 
    }
    public  function getController(){
       return $this->defineModel(0,$_SERVER["QUERY_STRING"])."_".$this->$c_ext;
    }
    public  function getModel(){
       return $this->defineModel(0,$_SERVER["QUERY_STRING"])."_".$this->$m_ext;
    }
    public  function createObj(){
        $name = $this->getModel();
        $$name = new $name ;
    }
    public  function getView(){
       return $this->defineModel(1,$_SERVER["QUERY_STRING"]);
    }
    public  function getViewAction(){
        return $this->defineModel(1,$_SERVER["QUERY_STRING"])."Controller";
    }
    public  function getAppDirectory(){
         return $this->defineModel(0,$_SERVER["QUERY_STRING"]);
    }
    
    
    
}

?>